package com.focus.pay.wx.action.v2;

import com.focus.pay.wx.config.WxPayConfig;
import com.focus.pay.wx.constant.WxPayConstant;
import com.focus.pay.core.annation.PayOrderHandler;
import com.focus.pay.core.enums.ChannelTypeEnum;
import com.focus.pay.core.enums.Version;
import com.focus.pay.core.exception.PayException;
import com.focus.pay.core.pay.PayOrderInterface;
import com.focus.pay.core.utils.HttpClientUtils;
import com.focus.pay.wx.model.order.v2.WxPayModelCodeBar;
import com.focus.pay.wx.model.order.v2.WxPayModelCodeBarResponse;

/**
* @Author: 赵参谋
* @Date: 2021/10/11 17:47
* @Description: 微信条码付
 * <link>https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=5_1</link>
*/
@PayOrderHandler(channelType = ChannelTypeEnum.WxType.BarCode,version = Version.VERSION_2)
public class WxPayOrderCodeBar extends WxPayOrder implements PayOrderInterface<WxPayModelCodeBarResponse, WxPayModelCodeBar, WxPayConfig> {

    @Override
    public WxPayModelCodeBarResponse payOrder(WxPayModelCodeBar wxPayModelCodeBar, WxPayConfig wxPayConfig) throws PayException {
        String res = HttpClientUtils.doPost(
                buildRequestPath(WxPayConstant.WxPayPathV2.PAY_ORDER_BAR),
                buildRequestParam(wxPayModelCodeBar,wxPayConfig));
        return resolvingResult(res,WxPayModelCodeBarResponse.class);

    }
}
